package com.delivery.www.servlet;

import com.delivery.www.po.Seller;
import com.delivery.www.service.ServiceImpl.DishServiceImpl;

import java.util.Scanner;
import java.util.concurrent.TimeUnit;

import static com.delivery.www.servlet.SellerDishPage.dishesList;

public class AddDish {
    public static void addDish(int storeId, Seller seller){
        DishServiceImpl dishService = new DishServiceImpl();
        Scanner scanner = new Scanner(System.in);
        boolean b = false;
        while (true) {
            System.out.println("请增加的菜品名:");
            String name = scanner.next();
            System.out.println("请输入增加的菜品价格:");
            Float price = scanner.nextFloat();
            System.out.println("请输入增加的菜品描述:");
            String describe = scanner.next();
            b = dishService.addDish(name, storeId, price, describe);
            if (b) {
                break;
            } else {
                System.out.println("添加失败,请重新添加");
            }
        }
        System.out.println("添加成功，即将跳转");
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        dishesList(storeId, seller);
    }
}
